import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig } from 'vite'

const timeStamp = new Date().getTime()
export default defineConfig({
  plugins: [
    vue()
  ],
  base: './',
  // 路径别名
  resolve: {
    alias: {
      '@': path.resolve('src')
    },
    extensions: ['.css', '.js', '.json', '.vue', '.mjs']
  },
  // 开发时候的端口号，默认为3001
  server: {
    host: '0.0.0.0',
    port: 8012
  },
  // 打包配置
  build: {
    // 打包文件夹名称
    outDir: 'exam-h5',
    // 开启压缩
    minify: true,
    compress: {
      drop_console: true,
      drop_debugger: true
    },
    // 打包后的文件名
    rollupOptions: {
      output: {
        entryFileNames: `assets/[name].${timeStamp}.js`,
        chunkFileNames: `assets/[name].${timeStamp}.js`,
        assetFileNames: `assets/[name].${timeStamp}.[ext]`,
      }
    }
  }
})
